package com.eduask.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.eduask.md5.Md5;
import com.eduask.model.User;
import com.eduask.service.UserService;


@Controller
@RequestMapping("/judge")
public class Judge {
	
	@Autowired
	private UserService userservice;
	
	@RequestMapping("loginjudge")
	@ResponseBody
	public Object loginjudge(User user){
		Md5 m=new Md5();
		user.setPassword(m.GetMd5(user.getUsername()));
		System.out.println(user);
		if(userservice.selectuser(user)){
			System.out.println("1");
			return true;
		}else{
			System.out.println("2");
			return false;
		}
	}
	
	@RequestMapping("email")
	@ResponseBody
	public Object email(HttpServletRequest req){
		int a=Integer.valueOf(req.getParameter("eid"));
		return JSON.toJSON(userservice.seeEmail(a));
	}
	
	
}
